package sbu.cs.ui.widget;

import android.content.Context;
import android.graphics.Color;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.view.MotionEvent;
import android.view.View;

import android.view.View.OnTouchListener;

public class MainMenuItem extends RelativeLayout implements OnTouchListener {

	private TextView textView;
	
	public MainMenuItem(Context context, String text) {
		super(context);
		init(text);
	}

	private void init(String text){
		setBackgroundColor(Color.BLACK);
		textView = new TextView(getContext());
		textView.setText(text);
		textView.setTextSize((float) 25);
		
		RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
				RelativeLayout.LayoutParams.FILL_PARENT,
				RelativeLayout.LayoutParams.FILL_PARENT
				);
		lp.topMargin = 12;
		lp.leftMargin=57;
		lp.addRule(RelativeLayout.CENTER_VERTICAL);
		addView(textView,lp);
		
		setOnTouchListener(this);
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		if(event.getAction() == MotionEvent.ACTION_DOWN){
			setBackgroundColor(Color.GRAY);
		}
		if(event.getAction() == MotionEvent.ACTION_UP){
			setBackgroundColor(Color.BLACK);
			v.performClick();
		}
		return true;
	}

	
}
